package com.bdqn.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bdqn.base.mybatis.ServiceImpl;
import com.bdqn.mapper.UserMapper;
import com.bdqn.pojo.User;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * 用户业务实现
 *
 * @author LILIBO
 * @since 2021-06-29
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;

    /**
     * 根据ID修改密码
     *
     * @param usrId
     * @param newPassword 新密码
     * @return
     */
    @Override
    public User resetPassword(Long usrId, String newPassword) {
        return null;
    }

    /**
     * 用户登录
     *
     * @param usrName
     * @return
     */
    @Override
    public User getUser(String usrName) {
        return null;
    }

    /**
     * 用户登录（获取用户及对应角色信息）
     *
     * @param usrName
     * @param usrPassword
     * @return
     */
    @Override
    public User loginUser(String usrName, String usrPassword) {
        if (!(StringUtils.hasLength(usrName) && StringUtils.hasLength(usrPassword))) {
            return null;
        }
        User user = userMapper.getLoginUser(usrName);
        if (!usrPassword.equals(user.getUsrPassword())) {
            return null;
        }
        return user;
    }

    /**
     * 分页获得用户数据
     *
     * @param user 条件信息封装
     * @param currPageNo 查询第几页
     * @param pageSize 每页多少条
     * @return
     */
    @Override
    public IPage<User> findUserRolePager(User user, int currPageNo, int pageSize) {
        return null;
    }
}
